#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
int judge_hz(char* arr0, char* arr1, int la)
{
	int rem = 0; int flag = 0;
	for (rem = 0; rem < la; rem++) {
		for (int i = 0, p1 = rem; i < la; i++, p1 = (p1 + 1) % la) {
			if (arr0[p1] != arr1[i])goto end;
		}
		flag = 1;
		break;
	end:;
	}
	return flag;
}
int main()
{
	char arr0[20];
	char arr1[20];
	scanf("%s", arr0);
	scanf("%s", arr1);
	int la = strlen(arr0);
	printf("%d\n", judge_hz(arr0, arr1, la));
	return 0;
}